package action.comment;

import service.ArticleService;
import service.CommentService;
import service.UserService;
import bean.ArticleComment;

import com.opensymphony.xwork2.ActionSupport;

public class CommentArticleAction extends ActionSupport {
	private int articleid;
	private ArticleComment articleComment;
	private CommentService commentService;
	private UserService userService;
	private ArticleService articleService;
	
	@Override
	public String execute() throws Exception {
		articleComment.setArticle(articleService.getArticleById(articleComment.getArticle().getId()));
		System.out.println(articleComment.getUser().getId());
		articleComment.setUser(userService.viewUserById(articleComment.getUser().getId()));
		commentService.addComment(articleComment);
		articleid=articleComment.getArticle().getId();
		return SUCCESS;
	}

	public ArticleComment getArticleComment() {
		return articleComment;
	}

	public void setArticleComment(ArticleComment articleComment) {
		this.articleComment = articleComment;
	}

	public CommentService getCommentService() {
		return commentService;
	}

	public void setCommentService(CommentService commentService) {
		this.commentService = commentService;
	}

	public int getArticleid() {
		return articleid;
	}

	public void setArticleid(int articleid) {
		this.articleid = articleid;
	}

	public UserService getUserService() {
		return userService;
	}

	public void setUserService(UserService userService) {
		this.userService = userService;
	}

	public ArticleService getArticleService() {
		return articleService;
	}

	public void setArticleService(ArticleService articleService) {
		this.articleService = articleService;
	}
	
	
}
